home *** CD-ROM | disk | FTP | other *** search
/ Thinkin' Science - 1st & 2nd Grades / Thinkin' Science - First and Second Grades (Edmark)(Version 1.0)(1997).ISO / pc / edinst / win32s / 32sinst.mst < prev    next >
Text File  |  1996-04-06  |  26KB  |  745 lines

  1. '**************************************************************************
  2. '*                  MS Test script for Win32s setup program
  3. '**************************************************************************
  4.  
  5. '' $DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME                  = 100
  12. CONST ASKQUIT                  = 200
  13. CONST DESTPATH                 = 300
  14. CONST EXITFAILURE              = 400
  15. CONST EXITQUIT                 = 600
  16. CONST EXITSUCCESS              = 700
  17. CONST OPTIONS                  = 800
  18. CONST BADPATH                  = 6400
  19.  
  20. CONST HELPWELCOME              = 1000
  21. CONST VERPATH                  = 1100
  22. CONST EXITFAILNOTWIN31         = 1200
  23. CONST EXITFAILNOTENH           = 1300
  24. CONST EXITFAILNOTPAGING        = 1325
  25. CONST EXITFAILNOTINTEL         = 1350
  26. CONST EXITFAILRUNAPP           = 1360
  27. CONST FREECELLINST             = 1400
  28. CONST FREECELLINSTNOWIN32S     = 1450
  29. CONST FREECELLPATH             = 1500
  30. CONST HELPFREECELL             = 1600
  31.  
  32.  
  33. ''Bitmap ID
  34. CONST LOGO = 1
  35.  
  36. ''GetTempFileName flags
  37. CONST TF_FORCEDRIVE            = 128
  38.  
  39. GLOBAL DESTWIN$      ''Windows directory.
  40. GLOBAL DESTSYS$      ''Windows\System directory.
  41. GLOBAL DEST32S$      ''Windows\System\Win32s directory
  42. GLOBAL DESTFREE$     ''Freecell directory
  43. GLOBAL OLE_PROTECT%  ''Indicates whether ole2 dlls were protected from being
  44.                      '' copied.
  45. GLOBAL OLE_OLEBOOT%
  46. GLOBAL VERNUM$       '' Win32s Version Number (i.e., for v1.25 VERNUM$="125"
  47.  
  48. DECLARE SUB Install(OLEINCLUDED%, OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%)
  49. DECLARE SUB RecoverFromCopy(szFileName$)
  50. DECLARE FUNCTION UpdateSystemIni AS INTEGER
  51. DECLARE FUNCTION RebootSystem(OLEONLY%) AS INTEGER
  52. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  53. DECLARE FUNCTION MakeSystemIni LIB "INIUPD.DLL" (arg1$, arg2$) AS INTEGER
  54. DECLARE FUNCTION RestartWindows LIB "INIUPD.DLL" AS INTEGER
  55. DECLARE FUNCTION OnWindowsNT LIB "INIUPD.DLL" AS INTEGER
  56. DECLARE FUNCTION PagingEnabled LIB "INIUPD.DLL" AS INTEGER
  57. DECLARE FUNCTION ShareEnabled LIB "INIUPD.DLL" AS INTEGER
  58. DECLARE FUNCTION IsWin32sLoaded LIB "INIUPD.DLL" (arg1$) AS INTEGER
  59. DECLARE FUNCTION IsRunningApp LIB "INIUPD.DLL" AS INTEGER
  60. DECLARE FUNCTION SetCuiFlags LIB "MSCUISTF.DLL" (arg1%, arg2%) AS INTEGER
  61. DECLARE FUNCTION ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER
  62. DECLARE FUNCTION GetModuleHandle LIB "KRNL386.EXE" (arg1$) AS INTEGER
  63. DECLARE FUNCTION LoadLibrary LIB "KRNL386.EXE" (arg1$) AS INTEGER
  64. DECLARE SUB FreeLibrary LIB "KRNL386.EXE" (arg1%)
  65. DECLARE FUNCTION SetErrorMode LIB "KRNL386.EXE" (arg1%) AS INTEGER
  66.  
  67. DECLARE FUNCTION GetTempFileName LIB "KRNL386.EXE" (drive%, prefix$, u%, filename$) AS INTEGER
  68. DECLARE SUB WriteLine LIB "INIUPD.DLL" (filename$, text$)
  69. DECLARE FUNCTION GetTempFileAt(szDir$, szPrefix$) as string
  70. INIT:
  71.     CUIDLL$ = "mscuistf.dll"            '' Custom user interface dll
  72.     HELPPROC$ = "FHelpDlgProc"          '' Help dialog procedure
  73.     szOldVer$ ="1.00.000     "          '' Reserve space in string for version
  74.     WIN32ENABLED% = 0
  75.     OLEONLY% = 0
  76.     OLE2_16% = 0
  77.     OLE2AUTO_16% = 0
  78.     OLE16RUNAPP% = 0
  79.     OLE_PROTECT% = 0
  80.     OLE_OLEBOOT% = 0
  81.  
  82.     ON ERROR GOTO ERRNORMAL
  83.  
  84.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  85.  
  86.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  87.     IF szInf$ = "" THEN
  88.         szInf$ = GetSymbolValue("STF_CWDDIR") + "32sinst.inf"
  89.     END IF
  90.     ReadInfFile szInf$
  91.  
  92.     SetBitmap CUIDLL$, LOGO
  93.  
  94.     WIN32SVER$ = MID$(GetSectionKeyVersion("WindowsSystem", "win32s16"), 1, 4)
  95.     SetTitle "Microsoft Win32s version " + WIN32SVER$ + " Setup Program"
  96.     VERNUM$ = MID$(WIN32SVER$, 1, 1) + MID$(WIN32SVER$, 3 , 2)
  97.  
  98.     DESTWIN$ = GetWindowsDir()
  99.     DESTSYS$ = GetWindowsSysDir()
  100.     DEST32S$ = DESTSYS + "WIN32S\"
  101.  
  102. '$IFDEF DEBUG
  103.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  104.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  105.     IF IsDriveValid(WinDrive$) = 0 THEN
  106.         i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  107.         GOTO QUIT
  108.     END IF
  109. '$ENDIF ''DEBUG
  110.  
  111. CHECK:
  112.     '' Can not run on versions less than 3.10.
  113.     IF GetWindowsMajorVersion < 3 THEN
  114.         ExitCode% = EXITFAILNOTWIN31
  115.         GOTO QUIT
  116.     END IF
  117.     IF GetWindowsMajorVersion = 3 AND GetWindowsMinorVersion < 10 THEN
  118.         ExitCode% = EXITFAILNOTWIN31
  119.         GOTO QUIT
  120.     END IF
  121.     '' Check that we are not runnig on Chicago, including pre-released
  122.     '' Chicago versions.
  123.     IF GetWindowsMajorVersion * 100 + GetWindowsMinorVersion > 350 THEN
  124.         ExitCode% = EXITSUCCESS
  125.         WIN32ENABLED% = 1
  126.         GOTO FREECELL
  127.     END IF
  128.     IF GetWindowsMode < 2  THEN
  129.         IF OnWindowsNT() THEN
  130.             ExitCode% = EXITFAILNOTINTEL '' Running on Windows NT (on RISC)
  131.         ELSE
  132.             ExitCode% = EXITFAILNOTENH   '' Standard Mode Windows
  133.         END IF
  134.         GOTO QUIT
  135.     END IF
  136.     IF OnWindowsNT() THEN
  137.         ExitCode% = EXITSUCCESS
  138.         WIN32ENABLED% = 1
  139.         GOTO FREECELL
  140.     END IF
  141.     ExitCode% = EXITSUCCESS
  142.  
  143.     if IsRunningApp() <> 0 THEN
  144.         ExitCode% = EXITFAILRUNAPP
  145.         GOTO QUIT
  146.     END IF
  147.  
  148.     '' Get version of Win32s to be installed from version info in INF file
  149.     szNewVer$ = GetSectionKeyVersion("WindowsSystem", "win32s16")
  150.  
  151.     '' See if OLE is included.
  152.  
  153.     OLEINCLUDED% = DoesFileExist( GetSymbolValue("STF_SRCDIR") + "OLE2THK.DL_", femExists )
  154.     '' Do the same for ole2thk.dll, if it is not compressed
  155.     OLEINCLUDED% = OLEINCLUDED% OR DoesFileExist( GetSymbolValue("STF_SRCDIR") + "OLE2THK.DLL", femExists )
  156.  
  157.     IF OLEINCLUDED% = 1 THEN
  158.         '' See whether one of the OLE 16 bit components is loaded.
  159.         IF GetModulehandle("compobj") <> 0 THEN
  160.             OLE16RUNAPP% = 1
  161.             GOTO GetOleVersion
  162.         END IF
  163.         IF GetModuleHandle("ole2") <> 0 THEN
  164.             OLE16RUNAPP% = 1
  165.             GOTO GetOleVersion
  166.         END IF
  167.         IF GetModuleHandle("ole2prox") <> 0 THEN
  168.             OLE16RUNAPP% = 1
  169.             GOTO GetOleVersion
  170.         END IF
  171.         IF GetModuleHandle("ole2conv") <> 0 THEN
  172.             OLE16RUNAPP% = 1
  173.             GOTO GetOleVersion
  174.         END IF
  175.         IF GetModuleHandle("storage") <> 0 THEN
  176.             OLE16RUNAPP% = 1
  177.             GOTO GetOleVersion
  178.         END IF
  179.         IF GetModuleHandle("ole2nls") <> 0 THEN
  180.             OLE16RUNAPP% = 1
  181.             GOTO GetOleVersion
  182.         END IF
  183.         IF GetModuleHandle("ole2disp") <> 0 THEN
  184.             OLE16RUNAPP% = 1
  185.             GOTO GetOleVersion
  186.         END IF
  187.         IF GetModuleHandle("typelib") <> 0 THEN
  188.             OLE16RUNAPP% = 1
  189.             GOTO GetOleVersion
  190.         END IF
  191.  
  192. GetOleVersion:
  193.         szOleNewVer$ = GetSectionKeyVersion("OleWindowsSystemWin32s", "ole2thk")
  194.  
  195.         '' Get version of currently installed OLE32 from version info of
  196.         '' ole2thk file
  197.         szOleOldVer$ = GetVersionOfFile( DESTSYS$ + "WIN32S\OLE2THK.DLL" )
  198.  
  199.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "COMPOBJ.DLL" )
  200.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "compobj")
  201.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  202.             OLE2_16% = 1
  203.         END IF
  204.  
  205.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2.DLL" )
  206.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2")
  207.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  208.             OLE2_16% = 1
  209.         END IF
  210.  
  211.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2PROX.DLL" )
  212.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2prox")
  213.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  214.             OLE2_16% = 1
  215.         END IF
  216.  
  217.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "STORAGE.DLL" )
  218.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "storage")
  219.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  220.             OLE2_16% = 1
  221.         END IF
  222.  
  223.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2CONV.DLL" )
  224.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2conv")
  225.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  226.             OLE2_16% = 1
  227.         END IF
  228.  
  229.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2NLS.DLL" )
  230.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2nls")
  231.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  232.             OLE2AUTO_16% = 1
  233.         END IF
  234.  
  235.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2DISP.DLL" )
  236.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2disp")
  237.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  238.             OLE2AUTO_16% = 1
  239.         END IF
  240.  
  241.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "TYPELIB.DLL" )
  242.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "typelib")
  243.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  244.             OLE2AUTO_16% = 1
  245.         END IF
  246.  
  247.     END IF
  248.  
  249.     OLE2_32% = OLEINCLUDED%
  250.  
  251.     '' Check if Win32s is partially installed
  252.     sz$ = GetIniKeyString (DESTSYS$ + "WIN32S.INI", "Win32s", "Setup")
  253.     '' If WIN32S.INI specifies Win32s Setup=0, then force complete Win32s file overwrite
  254.     IF sz$ = "0" THEN
  255.         GOTO WELCOME
  256.     END IF
  257.     '' If WIN32S.INI is missing, try and reinstall Win32s files/recreate WIN32S.INI
  258.     IF sz$ <> "1" THEN
  259.         GOTO WELCOME
  260.     END IF
  261.  
  262.     '' If Win32s is already installed, get running version number
  263.     i% = DoesFileExist( DESTSYS$ + "W32SYS.DLL", femExists )
  264.     IF i% = 1 THEN
  265.         i% = IsWin32sLoaded( szOldVer$ )
  266.     ENDIF
  267.  
  268.     IF i% = 0 THEN
  269.         GOTO WELCOME
  270.     END IF
  271.  
  272.     IF szNewVer$ > szOldVer$ THEN
  273.         GOTO WELCOME
  274.     END IF
  275.  
  276.     IF OLEINCLUDED% = 1 THEN
  277.  
  278.         OLE2_32% = 0
  279.  
  280.         IF (szNewVer$ = szOldVer$) OR (szNewVer$ < szOldVer$) THEN
  281.             '' Compare OLE32 version and versions of each of OLE16 libraries.
  282.             sz$ = GetIniKeyString (DESTSYS$ + "WIN32S.INI", "OLE", "Setup")
  283.             '' If WIN32S.INI specifies OLE2 Setup=0, then force OLE2 file overwrite
  284.             IF ((sz$ <> "1") OR (szOleNewVer$ > szOleOldVer$)) THEN
  285.                 OLEONLY% = 1
  286.                 OLE2_32% = 1
  287.                 GOTO WELCOME
  288.             END IF
  289.  
  290.             IF OLE2_16% OR OLE2AUTO_16 THEN
  291.                 OLEONLY% = 1
  292.                 GOTO WELCOME
  293.             END IF
  294.  
  295.         END IF
  296.  
  297.     END IF
  298.  
  299.     WIN32ENABLED% = 1
  300.     GOTO FREECELL
  301.  
  302. WELCOME:
  303.     i% = SetCuiFlags(OLEONLY%, OLE16RUNAPP%)
  304.     'sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", HELPWELCOME, HELPPROC$)
  305.     'IF sz$ = "CONTINUE" THEN
  306.         'UIPop 1
  307.     'ELSE
  308.         'UIPop 1
  309.         'GOSUB ASKQUIT
  310.         'GOTO WELCOME
  311.     'END IF
  312.  
  313.  
  314. GETWIN32SPATH:
  315.     IF PagingEnabled() = 0 THEN
  316.         i% = DoMsgBox("Use the Control Panel 386 Enhanced icon and configure Windows using the Virtual Memory option.", "Win32s requires Virtual Memory", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  317.         ExitCode% = EXITFAILURE '' Enhanced mode but not paging
  318.         GOTO QUIT
  319.     END IF
  320.  
  321.     IF ShareEnabled() = 0 THEN
  322.         i% = DoMsgBox( "File-sharing must be enabled. Run SHARE.EXE before starting Windows or add SHARE.EXE to your AUTOEXEC.BAT file.", "Win32s Setup: SHARE.EXE is not loaded", MB_TASKMODAL+MB_ICONEXCLAMATION+MB_OK)
  323.     END IF
  324.  
  325.     SetSymbolValue "EditTextIn", DESTSYS$
  326.     SetSymbolValue "EditFocus", "END"
  327.  
  328. GETPATHL1:
  329.     'sz$ = UIStartDlg(CUIDLL$, VERPATH, "FDispDlgProc", HELPWELCOME, HELPPROC$)
  330.  
  331.     'IF sz$ = "CONTINUE" THEN
  332.         'IF IsDirWritable(DESTSYS$) = 0 THEN
  333.             'GOSUB BADPATH
  334.             'GOTO GETPATHL1
  335.         'END IF
  336.         'UIPop 1
  337.     'ELSEIF sz$ = "REACTIVATE" THEN
  338.         'UIPop 1
  339.         'GOTO GETPATHL1
  340.     'ELSEIF sz$ = "BACK" THEN
  341.         'UIPop 1
  342.         'GOTO WELCOME
  343.     'ELSE
  344.         'UIPop 1
  345.         'GOSUB ASKQUIT
  346.         'GOTO GETPATHL1
  347.     'END IF
  348.  
  349. COPYFILES:
  350.     IF OLEONLY% = 0 THEN
  351.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  352.     END IF
  353.     IF OLE2_32% = 1 THEN
  354.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "OLE", "Setup", "0", cmoOverwrite
  355.     END IF
  356.  
  357.     '' Indicate Win32s install failure until all files known to be copied.
  358.     ExitCode% = EXITFAILURE
  359.     ERR = 0
  360.     CreateDir DEST32S$, cmoNone
  361.     Install OLEINCLUDED%, OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%
  362.     i% = UpdateSystemIni
  363.     '' Terminate if unhandled fatal error
  364.     IF (ERR <> 0) OR (i% = 0) THEN
  365.     GOTO QUIT
  366.     END IF
  367.  
  368.     IF OLEONLY% = 0 THEN
  369.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite
  370.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Version", szNewVer$, cmoOverwrite
  371.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Nls", "AnsiCP", "1252", cmoOverwrite
  372.     END IF
  373.     IF OLE2_32% = 1 THEN
  374.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "OLE", "Setup", "1", cmoOverwrite
  375.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "OLE", "Version", szOleNewVer, cmoOverwrite
  376.     END IF
  377.  
  378.     'i% = DoMsgBox("Win32s files successfully installed.", "Microsoft Win32s Setup", MB_OK+MB_TASKMODAL)
  379.     '' Indicate Win32s correctly copied and installed.
  380.     'ExitCode% = EXITSUCCESS
  381.  
  382. FREECELL:
  383.     'IF OLEONLY% = 1 THEN
  384.         'GOTO QUIT
  385.     'ENDIF
  386.     'IF WIN32ENABLED% = 1 THEN
  387.         'sz$ = UIStartDlg(CUIDLL$, FREECELLINSTNOWIN32S, "FInfoDlgProc",0, "")
  388.     'ELSE
  389.         'sz$ = UIStartDlg(CUIDLL$, FREECELLINST, "FInfoDlgProc",0, "")
  390.     'END IF
  391.     'UIPop 1
  392.     'IF sz$ <> "CONTINUE" THEN
  393.         'GOTO QUIT
  394.     'END IF
  395.  
  396. GETFREEPATH:
  397.     'DESTFREE$ = MID$(DESTSYS$,1,3) + "WIN32APP\FREECELL\"
  398.     'SetSymbolValue "EditTextIn", DESTFREE$
  399.     'SetSymbolValue "EditFocus", "END"
  400.  
  401. GETFREEPATHL1:
  402.     'sz$ = UIStartDlg(CUIDLL$, FREECELLPATH, "FEditDlgProc", HELPFREECELL, HELPPROC$)
  403.  
  404.     'IF sz$ = "CONTINUE" THEN
  405.         'DESTFREE$ = GetSymbolValue("EditTextOut")
  406.  
  407.         'IF MID$(DESTFREE$, LEN(DESTFREE$), 1) <> "\" THEN
  408.             'DESTFREE$ = DESTFREE$ + "\"
  409.         'END IF
  410.         ''Validate new path.
  411.         'IF IsDirWritable(DESTFREE$) = 0 THEN
  412.             'GOSUB BADPATH
  413.             'GOTO GETFREEPATHL1
  414.         'END IF
  415.         'UIPop 1
  416.  
  417.         'GOTO COPYFREECELL
  418.     'ELSEIF sz$ = "REACTIVATE" THEN
  419.         'GOTO GETFREEPATHL1
  420.     'ELSEIF sz$ = "EXIT" THEN
  421.         'UIPop 1
  422.         'GOTO QUIT
  423.     'END IF
  424.  
  425. COPYFREECELL:
  426.     'ClearCopyList
  427.     'CreateDir DESTFREE$, cmoNone
  428.  
  429.     'SrcDir$ = GetSymbolValue("STF_SRCDIR")
  430.  
  431.     'ERR = 0
  432.     'AddSectionFilesToCopyList "Win32appFreecell", SrcDir$, DESTFREE$
  433.     'CopyFilesInCopyList
  434.     '' If error copying FreeCell, not a fatal error. Win32s is already installed.
  435.     'IF ERR <> 0 THEN
  436.     'ERR = 0
  437.     'GOTO QUIT
  438.     'END IF
  439.     'ERR = 0
  440.  
  441.     'IF DoesFileExist( DESTSYS$ + "WIN32S.INI", femExists ) THEN
  442.     'CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Freecell", "Setup", "1", cmoOverwrite
  443.     'CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Freecell", "Version", szNewVer$, cmoOverwrite
  444.     'END IF
  445.  
  446.     'ERR = 0
  447.     'CreateProgmanGroup "Win32 Applications", "", cmoNone
  448.     'ShowProgmanGroup   "Win32 Applications", 1, cmoNone
  449.     'CreateProgmanItem  "Win32 Applications", "Freecell", DESTFREE$ + "FREECELL.EXE", "", cmoOverwrite
  450.     '' Only put up success dialog if icon added to group
  451.     'IF ERR = 0 THEN
  452.     'i% = DoMsgBox("Freecell was successfully installed.", "Freecell Setup", MB_OK+MB_TASKMODAL)
  453.     'END IF
  454.     'ERR = 0
  455.  
  456. QUIT:
  457.     '' Install error handler for final message box routines
  458.     i% = DoesFileExist( GetWindowsDir() + "_MSSETUP.BAT", femExists )
  459.     IF i% = 1 THEN
  460.         CopyFile GetWindowsDir() + "_MSSETUP.BAT", GetWindowsDir() + "_SETUP.BAT", cmoNone, 1
  461.     END IF
  462.  
  463.     ON ERROR GOTO ERRQUIT
  464.     IF ERR = 0 THEN
  465.         'dlg% = ExitCode%
  466.     ELSEIF ERR = STFQUIT THEN
  467.         IF (OLE_PROTECT% = 1) THEN
  468.             '' Free all previously loaded libraries
  469.             FreeLibrary GetModuleHandle("compobj")
  470.             FreeLibrary GetModuleHandle("ole2")
  471.             FreeLibrary GetModuleHandle("ole2prox")
  472.             FreeLibrary GetModuleHandle("ole2conv")
  473.             FreeLibrary GetModuleHandle("storage")
  474.             FreeLibrary GetModuleHandle("ole2nls")
  475.             FreeLibrary GetModuleHandle("ole2disp")
  476.             FreeLibrary GetModuleHandle("typelib")
  477.         END IF
  478.         'dlg% = EXITQUIT
  479.         ExitCode% = EXITQUIT
  480.     ELSE
  481.         'dlg% = EXITFAILURE
  482.         ExitCode% = EXITQUIT
  483.     END IF
  484.  
  485. QUITL1:
  486.     IF WIN32ENABLED% = 1 THEN
  487.         'UIPop 1
  488.         END
  489.     END IF
  490.  
  491.     'sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  492.     'IF sz$ = "REACTIVATE" THEN
  493.         'GOTO QUITL1
  494.     'END IF
  495.     'UIPop 1
  496.  
  497.     IF ExitCode% = EXITSUCCESS THEN
  498.         IF RebootSystem(OLEONLY% and not OLE_OLEBOOT%) = 0 THEN
  499.             CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  500.             IF OLE2_32% = 1 THEN
  501.                 CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "OLE", "Setup", "0", cmoOverwrite
  502.             END IF
  503.             i% = DoMsgBox("Win32s is not properly configured and Win32s Setup must be run again.", "Unable to Restart Windows", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL)
  504.         END IF
  505.     ENDIF
  506.  
  507.     END
  508.  
  509. '' Fatal error handler for error message routine
  510. ERRQUIT:
  511.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  512.     END
  513.  
  514. '' Bypass run-time errors. Let final dialog box display fatal error message.
  515. ERRNORMAL:
  516.     '' Check if user cancelled setup
  517.     IF ERR = STFQUIT THEN
  518.     GOTO QUIT
  519.     END IF
  520.     RESUME NEXT
  521.  
  522.  
  523. BADPATH:
  524.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  525.     IF sz$ = "REACTIVATE" THEN
  526.         GOTO BADPATH
  527.     END IF
  528.         UIPop 1
  529.     RETURN
  530.  
  531.   ASKQUIT:
  532.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  533.  
  534.     IF sz$ = "EXIT" THEN
  535.         UIPop 1
  536.         UIPopAll
  537.         ERROR STFQUIT
  538.     ELSEIF sz$ = "REACTIVATE" THEN
  539.         GOTO ASKQUIT
  540.     ELSE
  541.         UIPop 1
  542.     END IF
  543.     RETURN
  544.  
  545.  
  546.  
  547. '**
  548. '** Purpose:
  549. '**     Builds the copy list and performs all installation operations.
  550. '** Arguments:
  551. '**     none.
  552. '** Returns:
  553. '**     none.
  554. '*************************************************************************
  555. SUB Install(OLEINCLUDED%, OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%) STATIC
  556.  
  557.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  558.  
  559.     '' Use file layout sections that specify OLDER file version/time check
  560.     IF OLEONLY% = 0 THEN
  561.         AddSectionFilesToCopyList "WindowsSystem", SrcDir$, DESTSYS$
  562.         AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  563.         '' Add obsolete files to be removed
  564.         AddSectionFilesToCopyList "Win32sSystemObsoleteFiles", SrcDir$, DESTSYS$ + "WIN32S\"
  565.     END IF
  566.  
  567.     OLE_PROTECT% = 0
  568.     if OLEINCLUDED% = 1 THEN
  569.         IF (OLE2_16% = 1) OR (OLE2AUTO_16% = 1) THEN
  570.             IF OLE16RUNAPP% = 1 THEN
  571.                 '' Force all OLE2 DLLS to be copied during reboot.
  572.                 i% = SetErrorMode(-32768)
  573.                 i% = LoadLibrary(DESTSYS$ + "compobj.dll")
  574.                 i% = LoadLibrary(DESTSYS$ + "ole2.dll")
  575.                 i% = LoadLibrary(DESTSYS$ + "ole2prox.dll")
  576.                 i% = LoadLibrary(DESTSYS$ + "ole2conv.dll")
  577.                 i% = LoadLibrary(DESTSYS$ + "storage.dll")
  578.                 i% = LoadLibrary(DESTSYS$ + "ole2nls.dll")
  579.                 i% = LoadLibrary(DESTSYS$ + "ole2disp.dll")
  580.                 i% = LoadLibrary(DESTSYS$ + "typelib.dll")
  581.                 OLE_PROTECT% = 1
  582.             END IF
  583.             AddSectionFilesToCopyList "OleWindowsSystem", SrcDir$, DESTSYS$
  584.         END IF
  585.         IF OLE2_32% = 1 THEN
  586.             AddSectionFilesToCopyList "OleWindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  587.         END IF
  588.         IF (OLE2_16% = 1) OR (OLE2_32% = 1) OR (OLE2AUTO_16% = 1) THEN
  589.             AddSectionFilesToCopyList "Ole2RegWindowsSystem", SrcDir$, DESTSYS$
  590.         END IF
  591.         IF (OLE2AUTO_16% = 1) THEN
  592.             AddSectionFilesToCopyList "StdoleWindowsSystem", SrcDir$, DESTSYS$
  593.             IF (OLE16RUNAPP and DoesFileExist(DESTSYS$ + "stdole.tlb", femExists) ) THEN
  594.                 ' copy stdole.tlb -> tempfile1
  595.                 stdole1$ = DESTSYS$ + GetTempFileAt(DESTSYS$, "STD")
  596.                 CopyFile DESTSYS$+"STDOLE.TLB", stdole1$, cmoOverwrit, 0
  597.                 OLE_OLEBOOT% = 1
  598.             ENDIF
  599.         END IF
  600.     END IF
  601.  
  602.     SetRestartDir GetWindowsDir()
  603.  
  604.     CopyFilesInCopyList
  605.  
  606.     IF (OLEINCLUDED% = 1) THEN
  607.         RecoverFromCopy DESTSYS$ + "compobj.dll"
  608.         RecoverFromCopy DESTSYS$ + "ole2.dll"
  609.         RecoverFromCopy DESTSYS$ + "ole2prox.dll"
  610.         RecoverFromCopy DESTSYS$ + "ole2conv.dll"
  611.         RecoverFromCopy DESTSYS$ + "storage.dll"
  612.         RecoverFromCopy DESTSYS$ + "ole2nls.dll"
  613.         RecoverFromCopy DESTSYS$ + "ole2disp.dll"
  614.         RecoverFromCopy DESTSYS$ + "typelib.dll"
  615.     END IF
  616.  
  617.     IF (OLE_PROTECT% = 1) THEN
  618.         '' Free all previously loaded libraries
  619.         FreeLibrary GetModuleHandle("compobj")
  620.         FreeLibrary GetModuleHandle("ole2")
  621.         FreeLibrary GetModuleHandle("ole2prox")
  622.         FreeLibrary GetModuleHandle("ole2conv")
  623.         FreeLibrary GetModuleHandle("storage")
  624.         FreeLibrary GetModuleHandle("ole2nls")
  625.         FreeLibrary GetModuleHandle("ole2disp")
  626.         FreeLibrary GetModuleHandle("typelib")
  627.         OLE_PROTECT% = 0
  628.     END IF
  629.     IF (OLE_OLEBOOT% = 1) THEN
  630.             'rename new stdole.tlb -> tempfile2
  631.             stdole2$ = GetTempFileAt(DESTSYS$, "STD")
  632.             RemoveFile DESTSYS$+stdole2$, cmoForce
  633.             RenameFile DESTSYS$+"STDOLE.TLB" , stdole2$
  634.             'rename tempfile1 -> stdole.tlb
  635.             RenameFile stdole1$, "STDOLE.TLB"
  636.             'write to _mssetup.bat: rename tempfile2 to stdole.tlb
  637.             WriteLine DESTWIN$+"_MSSETUP.BAT", ""
  638.             WriteLine DESTWIN$+"_MSSETUP.BAT", "DEL "+DESTSYS$+"STDOLE.TLB"
  639.             WriteLine DESTWIN$+"_MSSETUP.BAT", "REN "+DESTSYS$+stdole2$+" STDOLE.TLB"
  640.     ENDIF
  641.     IF OLEINCLUDED% AND (OLE2_16% OR OLE2_32% OR OLE2AUTO_16%) THEN
  642.         IF OLE16RUNAPP% THEN
  643.             reg1$ = DESTWIN$ + GetTempFileAt(DESTWIN$, "REG")
  644.             CopyFile DESTWIN$+"REG.DAT", reg1$, cmoOverwrit, 0
  645.         ENDIF
  646.  
  647.         RUN "regedit /s " + DESTSYS$ + "ole2.reg"
  648.  
  649.         IF OLE16RUNAPP% THEN
  650.             reg2$ = GetTempFileAt(DESTWIN$, "REG")
  651.             RemoveFile DESTWIN$ + reg2$, cmoForce
  652.             RenameFile DESTWIN$ + "REG.DAT" , reg2$
  653.             'rename tempfile1 -> reg.dat
  654.             RenameFile reg1$, "REG.DAT"
  655.             'write to _mssetup.bat: rename tempfile2 to reg.dat
  656.             WriteLine DESTWIN$+"_MSSETUP.BAT", ""
  657.             WriteLine DESTWIN$+"_MSSETUP.BAT", "DEL "+DESTWIN$+"REG.DAT"
  658.             WriteLine DESTWIN$+"_MSSETUP.BAT", "REN "+DESTWIN$ + reg2$+" REG.DAT"
  659.             OLE_OLEBOOT% = 1
  660.         ENDIF
  661.     END IF
  662. END SUB
  663.  
  664. FUNCTION UpdateSystemIni STATIC AS INTEGER
  665.  
  666.     VxDPath$ = DEST32S$ + "W32S.386"
  667.     SystemIniPath$ = GetWindowsDir()
  668.  
  669.     UpdateSystemIni% = MakeSystemIni(SystemIniPath$, VxdPath$)
  670.  
  671. END FUNCTION
  672.  
  673. FUNCTION RebootSystem(OLEONLY%) STATIC AS INTEGER
  674.  
  675. '   Check if any files were locked during install.  If the RestartList
  676. '   is not empty, ExitExecRestart() will restart Windows, cleanup setup
  677. '   files, and copy over locked files before Windows restarts.
  678.     i% = RestartListEmpty()
  679.     IF i% = 0 THEN
  680. '      ExitExecRestart() only returns if applications refuse to be shutdown.
  681. '      Win32s is installed but will not operate until Windows is restarted
  682. '      and the Win32s VxD is loaded.
  683.        'i% = ExitExecRestart()
  684.        RebootSystem = 0
  685.        
  686.     ELSE
  687. '      If the RestartList list is empty, it is necessary to restart windows
  688. '      directly.  The MSSETUP program creates _MSRSTRT.EXE and _MSSETUP.BAT
  689. '      in the restart directory.  This program should be exec'd to handle
  690. '      proper MSSETUP cleanup (temp files) and restart Windows.
  691.        IF (OLEONLY% = 1) THEN
  692.            RebootSystem = 1
  693.        ELSE
  694.            'i% = ExitWindowsExec( GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT" )
  695.            RebootSystem = 0
  696.        END IF
  697.     ENDIF
  698.  
  699.     
  700.  
  701. END FUNCTION
  702.  
  703.  
  704. '**
  705. '** Purpose:
  706. '**     Appends a file name to the end of a directory path,
  707. '**     inserting a backslash character as needed.
  708. '** Arguments:
  709. '**     szDir$  - full directory path (with optional ending "\")
  710. '**     szFile$ - filename to append to directory
  711. '** Returns:
  712. '**     Resulting fully qualified path name.
  713. '*************************************************************************
  714. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  715.     IF szDir$ = "" THEN
  716.     MakePath = szFile$
  717.     ELSEIF szFile$ = "" THEN
  718.     MakePath = szDir$
  719.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  720.     MakePath = szDir$ + szFile$
  721.     ELSE
  722.     MakePath = szDir$ + "\" + szFile$
  723.     END IF
  724. END FUNCTION
  725.  
  726. FUNCTION GetTempFileAt(szDir$, szPrefix$) STATIC AS STRING
  727.     szCurDir$ = CURDIR$
  728.     CHDIR szDir$ + "."
  729.     szTempFile$ = STRING$(144, "E")
  730.     i% = GetTempFileName(TF_FORCEDRIVE, szPrefix$,0, szTempFile$)
  731.     CHDIR szCurDir$
  732.     GetTempFileAt = MID$(szTempFile$,3)
  733. END FUNCTION
  734.  
  735. SUB RecoverFromCopy(szFileName$) STATIC
  736.     IF DoesFileExist(szFileName$, femExist) = 0 THEN
  737.         szBackFile$ = MID$(szFileName$, 1, LEN(szFileName$)-3) + VERNUM$
  738.         IF DoesfileExist(szBackFile$, femExist) = 0 THEN
  739.             i% = DoMsgBox("ERROR: Could not find backup file "+szBackfile$, "Setup Error", MB_ICONEXLAMATION + MB_OK)
  740.         ELSE
  741.             CopyFile szBackFile$, szFileName$, cmoTimeStamp, 0
  742.         END IF
  743.     END IF
  744. END SUB
  745.